package com.ruoyi.framework.shiro.matcher;

import com.ruoyi.framework.shiro.token.CustomToken;
import com.ruoyi.framework.shiro.token.LoginType;
import org.apache.shiro.authc.AuthenticationInfo;
import org.apache.shiro.authc.AuthenticationToken;
import org.apache.shiro.authc.credential.SimpleCredentialsMatcher;

/**
 * 授权拦截
 */
public class MyRetryLimitCredentialsMatcher extends SimpleCredentialsMatcher {
    @Override
    public boolean doCredentialsMatch(AuthenticationToken authcToken, AuthenticationInfo info) {
        CustomToken token = (CustomToken) authcToken;
        /**
         * 免密拦截放行
         */
        if (token.getType().equals(LoginType.NOPASSWD)) {
            return true;
        }
        boolean matches = super.doCredentialsMatch(authcToken, info);
        return matches;
    }
}
